package demo.DataStrucAndAlgo.Easy_pritice;

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;

/**
 * @Auther: hjy(lc))
 * @Date: 2022/10/18-10-18-22:27
 * @Description：demo.DataStrucAndAlgo.Easy_pritice
 */
public class FileRemove {
    public static void main(String[] args) throws IOException {
        File file = new File("D:\\HelloWorld.txt");
        System.out.println("HelloWorld.txt是文件？" + file.isFile());

        File file1 = new File("D:\\IOTest");

        System.out.println(file1 + "是否创建成功：" + file1.mkdir());
        System.out.println(file.renameTo(new File(file1.getAbsolutePath() + File.separator + file.getName())));

        System.out.println("遍历目录：" + file1);
        String[] files = file1.list();
        for (String fileName : files) {
            System.out.println(fileName);
        }
    }
}
